jsx3.Class.defineClass(
        "tibco.admin.monitormanage.uicomponents.text.nodeInfo.NodeInfo", //the full name of the class to create
        jsx3.gui.Block, //  extends
        null, // implements
        function (plugin) {

            plugin.prototype.init = function() {
                this.jsxsuper();
            }

            plugin.prototype.setUpComponent = function() {
            	var subject = tibco.admin.monitormanage.uicomponents.page.gridInfrastructure.GridInfrastructure.nodeInfoCacheSubject;
            	tibco.admin.monitormanage.general.PageBusUtils.subscribe(subject, this.handleDisplayScreen, this);
            }

            plugin.prototype.handleDisplayScreen = function(subject, message, infoObj) {
            	infoObj.loadContent(infoObj);
            }

            plugin.prototype.loadContent = function(infoObj) {
           		var nodeInfoDoc = tibco.admin.Main.getServer().Cache.getDocument(tibco.admin.monitormanage.uicomponents.page.gridInfrastructure.GridInfrastructure.nodeScreenCacheId);
       		 	if(nodeInfoDoc)
       		 	{
           			var record = nodeInfoDoc.getFirstChild();

           			var nameField = infoObj.getDescendantOfName("nodeInfoName_MM_infra");
           			nameField.setText(record.getAttribute("name"));
           			//nameField.repaint();

           			var descriptionField = infoObj.getDescendantOfName("nodeInfoDescr_MM_infra");
           			descriptionField.setText(record.getAttribute("description"));
           			//descriptionField.repaint();

           			var installDateField = infoObj.getDescendantOfName("nodeInfoInstallDate_MM_infra");
           			installDateField.setText(record.getAttribute("installDate"));
           			//installDateField.repaint();

           			var installedByField = infoObj.getDescendantOfName("nodeInfoInstalledBy_MM_infra");
           			installedByField.setText(record.getAttribute("installedBy"));
           			//installedByField.repaint();

           			var messagingServerField = infoObj.getDescendantOfName("nodeInfoMsgingServer_MM_infra");
           			messagingServerField.setText(record.getAttribute("messagingServer"));
           			//messagingServerField.repaint();

           			var startDateField = infoObj.getDescendantOfName("nodeInfoStartDate_MM_infra");
                  	var startDateLong = record.getAttribute("startDate");
			var startDate;
			if(startDateLong == 0)
			{ startDate = tibco.admin.Main.getServer().getDynamicProperty("@MM@general@notApplicable"); }
			else
			{ startDate = tibco.admin.monitormanage.general.MonitorManageUtils.formatStartDateISO(startDateLong); }
                  // this is provided as a long datatype. it should be converted to date/time
           			startDateField.setText(startDate);
           			//startDateField.repaint();

           			var uptimeField = infoObj.getDescendantOfName("nodeInfoUptime_MM_infra");
           			var upTime = record.getAttribute("upTime");
           			upTime = tibco.admin.monitormanage.general.MonitorManageUtils.formatElapsedTime(upTime);
           			uptimeField.setText(upTime);
           			//uptimeField.repaint();

           			var cpuTimeField = infoObj.getDescendantOfName("nodeInfoCpuTime_MM_infra");
           			var cpuTime = record.getAttribute("cpuTime");
           			cpuTime = tibco.admin.monitormanage.general.MonitorManageUtils.formatElapsedTime(cpuTime/1000000);
           			cpuTimeField.setText(cpuTime, true);
           			//cpuTimeField.repaint();

           			var memoryField = infoObj.getDescendantOfName("nodeInfoMemory_MM_infra");
           			var memoryInUse = record.getAttribute("memoryInUse");
           			var totalMemory = record.getAttribute("totalMemory");
           			var memoryText = "";
           			if(memoryInUse && totalMemory)
           			{
	           			var memoryRatio = Math.round((memoryInUse / totalMemory) * 100);
	           			var progressFill;
						var server = tibco.admin.Main.getServer();
						   if(memoryRatio <= 50)
	           			{ progressFill = server.resolveURI('jsxaddin://user!MatrixAdmin/images/matrix/progressBarGreenFill.jpg'); }
	           			else if(memoryRatio <= 75)
	           			{ progressFill = server.resolveURI('jsxaddin://user!MatrixAdmin/images/matrix/progressBarYellowFill.jpg'); }
	           			else
	           			{ progressFill = server.resolveURI('jsxaddin://user!MatrixAdmin/images/matrix/progressBarRedFill.jpg'); }
	
	           			var backgroundImg = server.resolveURI('jsxaddin://user!MatrixAdmin/images/matrix/progressBarBkgrdTile_1px.jpg');
	           			memoryText = "<div style=\"width:100;border-left:1px solid #626262;border-right:1px solid #626262;background-image:url(" + backgroundImg + ");\"><div style=\"width:" + memoryRatio + ";background-image:url(" + progressFill + ");height:10px;\"></div></div>";
           			}
           			memoryField.setText(memoryText);
           			//memoryField.repaint();
					infoObj.repaint();
            	}
            }

        });
